package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhShop;
import com.ruoyi.xh.service.IXhShopService;

/**
 * 管理员Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "管理员Controller",value = "管理员Controller")
@RestController
@RequestMapping("/xh/shop")
public class XhShopController extends BaseController {

    @Autowired
    private IXhShopService xhShopService;

    /**
     * 查询管理员列表
     */
    @PreAuthorize("@ss.hasPermi('xh:shop:list')")
    @GetMapping("/list")
    @ApiOperation("查询管理员列表")
    public TablePageDataInfo<XhShop> list(XhShop xhShop) {
        return TablePageDataInfo.success(xhShopService.selectXhShopList(xhShop));
    }

    /**
     * 获取管理员详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:shop:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取管理员详细信息")
    public CommentResult<XhShop> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhShopService.selectXhShopById(id));
    }

    /**
     * 新增管理员
     */
    @PreAuthorize("@ss.hasPermi('xh:shop:add')")
    @Log(title = "管理员", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增管理员")
    public CommentResult<XhShop> add(@RequestBody XhShop xhShop) {
            xhShopService.insertXhShop(xhShop);
        return CommentResult.success();
    }

    /**
     * 修改管理员
     */
    @PreAuthorize("@ss.hasPermi('xh:shop:edit')")
    @Log(title = "管理员", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改管理员")
    public CommentResult<XhShop> edit(@RequestBody XhShop xhShop) {
            xhShopService.updateXhShop(xhShop);
        return CommentResult.success();
    }

    /**
     * 删除管理员
     */
    @PreAuthorize("@ss.hasPermi('xh:shop:remove')")
    @Log(title = "管理员", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除管理员")
    public CommentResult<XhShop> remove(@PathVariable Long[] ids) {
            xhShopService.deleteXhShopByIds(ids);
        return CommentResult.success();
    }
}
